﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Data;
using System.Text;
using System.Data.SqlClient;

namespace U9API.DBHelper.DAL
{

    public partial class DHAPI_Config
    {
        string constr = "";
        public DHAPI_Config(String _constr)
        {
            this.constr = _constr;
        }
        #region  BasicMethod
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public U9API.DBHelper.Model.DHAPI_Config GetModel(string ConfigCode)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from DHAPI_Config ");
            strSql.Append(" where ConfigCode=@ConfigCode ");
            SqlParameter[] parameters = {
					new SqlParameter("@ConfigCode", SqlDbType.VarChar,50)			};
            parameters[0].Value = ConfigCode;

            U9API.DBHelper.Model.DHAPI_Config model = new U9API.DBHelper.Model.DHAPI_Config();
            DataSet ds = Pub.DbHelperSQL.Query(strSql.ToString(), constr, parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public U9API.DBHelper.Model.DHAPI_Config DataRowToModel(DataRow row)
        {
            U9API.DBHelper.Model.DHAPI_Config model = new U9API.DBHelper.Model.DHAPI_Config();
            if (row != null)
            {
                if (row["sSubId"] != null)
                {
                    model.sSubId = row["sSubId"].ToString();
                }
                if (row["sServer"] != null)
                {
                    model.sServer = row["sServer"].ToString();
                }
                if (row["sYear"] != null && row["sYear"].ToString() != "")
                {
                    model.sYear = int.Parse(row["sYear"].ToString());
                }
                if (row["sUser"] != null)
                {
                    model.sUser = row["sUser"].ToString();
                }
                if (row["sPassword"] != null)
                {
                    model.sPassword = row["sPassword"].ToString();
                }
                if (row["ConfigCode"] != null)
                {
                    model.ConfigCode = row["ConfigCode"].ToString();
                }
                if (row["OrgCode"] != null)
                {
                    model.OrgCode = row["OrgCode"].ToString();
                }
            }
            return model;
        }

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}
